import request from '@/utils/request'

// 字典分类API
export const dictCategoryApi = {
  // 根据ID查询字典分类
  queryById(id) {
    return request({
      url: `/admin/dict-category/${id}`,
      method: 'GET'
    })
  },

  // 根据条件查询字典分类列表
  queryList(params) {
    return request({
      url: '/admin/dict-category/list',
      method: 'POST',
      data: params
    })
  },

  // 分页查询字典分类
  queryPage(pageNum, pageSize, params = {}) {
    return request({
      url: '/admin/dict-category/page',
      method: 'POST',
      params: {
        pageNum,
        pageSize,
        ...params
      }
    })
  },

  // 创建字典分类
  create(data) {
    return request({
      url: '/admin/dict-category',
      method: 'POST',
      data
    })
  },

  // 更新字典分类
  update(id, data) {
    return request({
      url: `/admin/dict-category/${id}`,
      method: 'PUT',
      data
    })
  },

  // 删除字典分类
  delete(id) {
    return request({
      url: `/admin/dict-category/${id}`,
      method: 'DELETE'
    })
  },

  // 批量删除字典分类
  deleteBatch(ids) {
    return request({
      url: '/admin/dict-category/batch',
      method: 'DELETE',
      data: ids
    })
  },

  // 根据分类代码查询字典分类
  queryCategoryByCode(code) {
    return request({
      url: `/admin/dict-category/code/${code}`,
      method: 'GET'
    })
  }
}

// 字典值API
export const dictItemApi = {
  // 根据ID查询字典值
  queryById(id) {
    return request({
      url: `/admin/dict-item/${id}`,
      method: 'GET'
    })
  },

  // 根据条件查询字典值列表
  queryList(params) {
    return request({
      url: '/admin/dict-item/list',
      method: 'POST',
      data: params
    })
  },

  // 分页查询字典值
  queryPage(pageNum, pageSize, params = {}) {
    return request({
      url: '/admin/dict-item/page',
      method: 'POST',
      params: {
        pageNum,
        pageSize,
        ...params
      }
    })
  },

  // 根据分类ID查询字典值列表
  queryByCategoryId(categoryId) {
    return request({
      url: `/admin/dict-item/category/${categoryId}`,
      method: 'GET'
    })
  },

  // 根据分类代码查询字典值列表
  queryByCategoryCode(categoryCode) {
    return request({
      url: `/admin/dict-item/category-code/${categoryCode}`,
      method: 'GET'
    })
  },

  // 创建字典值
  create(data) {
    return request({
      url: '/admin/dict-item',
      method: 'POST',
      data
    })
  },

  // 更新字典值
  update(id, data) {
    return request({
      url: `/admin/dict-item/${id}`,
      method: 'PUT',
      data
    })
  },

  // 删除字典值
  delete(id) {
    return request({
      url: `/admin/dict-item/${id}`,
      method: 'DELETE'
    })
  },

  // 批量删除字典值
  deleteBatch(ids) {
    return request({
      url: '/admin/dict-item/batch',
      method: 'DELETE',
      data: ids
    })
  }
}
